﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectEulerSolutions
{
    /*
     * By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

        What is the 10 001st prime number?

     * 
     * */
    class Problem7
    {
        public static string Calculate()
        {
            int target = 10001;

            int i = 1;
            int count = 0;

            do
            {
                i++;
                if (IsPrime(i))
                {
                    count++;
                    Console.WriteLine(i);
                }
            } while (count < target);

            return i.ToString();
        }

        public static bool IsPrime(int n)
        {
            if (n <= 0)
                return false;

            for (int i = 2; i <= (n / i); i++)
            {
                if (n % i == 0)
                    return false;
            }
            return true;
        }
    }
}
